//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    hello: '你好',
    userInfo: {},
    // 菜单
    menudata: [
      {
        title: '资讯动态',
        url: "/pages/news/index",
      }
      ,
      {
        title: '开心一刻',
        url: "/pages/haha/haha",
      },
      {
        title: '小工具类',
        url: "/pages/map/map",
      },
      {
        title: '地铁线路',
        url: "/pages/map/map",
      }, {
        title: '表情包',
        url: "/pages/map/map",
      }, {
        title: '进入地图',
        url: "/pages/map/map",
      }],
    color: "#fff",
    bgcolor: "#009688",
    bgcolorArr: ['#009688', '#5FB878', '#393D49', '#1E9FFF', '#e2e2e2']
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },

  onLoad: function () {

    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function (userInfo) {
      //更新数据
      that.setData({
        userInfo: userInfo
      })
    });
    // 创建随机数
    var n = 0,
      m = 5;
    var random = Math.floor(Math.random() * (m - n + 1) + n);
    console.log(random);
    that.setData({
      bgcolor: this.data.bgcolorArr[random]
    });
  }
})
